//
//  NSString+DateFormat.m
//  zjhealth
//
//  Created by 张润东 on 2018/12/26.
//  Copyright © 2018 amu. All rights reserved.
//

#import "NSString+DateFormat.h"
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@implementation NSString (DateFormat)


/**
 时间戳转-日期字符串
 @param format yyyy-MM-dd HH:mm   yyyy-MM-dd
 @return 您需要的字符串
 */
+(NSString*)getDayString:(NSString*)timestamp format:(NSString*)format{
    
    if (!timestamp.length) {
        return @"";
    }
    if (timestamp.length>10) {
        timestamp=[timestamp substringToIndex:timestamp.length-3];
    }
    long sec  = [timestamp longLongValue];
    NSDate *confromTimesp = [NSDate dateWithTimeIntervalSince1970:sec];
    NSDateFormatter *dateFormat=[[NSDateFormatter alloc]init];
    [dateFormat setDateFormat:format];
    NSString* string=[dateFormat stringFromDate:confromTimesp];
    return string;
}
@end
